package com.czk.grouptask;

import com.czk.pojo.Holiday;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author ChenZhangKun
 * @Date 2020/9/15 11:33
 */
@SuppressWarnings("all")
public class GroupTaskStartInstance {
    public static void main(String[] args) {
        startMethod_1();
    }
    public static void startMethod_1(){
        // 获取流程引擎
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 获取启动任务
        RuntimeService runtimeService = processEngine.getRuntimeService();
        // 启动实例
        Holiday holiday=new Holiday();
        holiday.setBeginTime(new Date());
        holiday.setNum(5.0f);
        holiday.setId(1);
        holiday.setReason("休息");
        holiday.setType("调休");
        Map<String, Object> map=new HashMap<>(10);
        map.put("holiday",holiday);
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("czk",map);
        // 打印信息
        System.out.println(processInstance.getName());
        System.out.println(processInstance.getId());
        System.out.println(processInstance.getStartTime());
    }
}

